//
//  OneLongImageTableViewCell.m
//  MusicNews
//
//  Created by lanou3g on 15/10/13.
//  Copyright © 2015年 LC.J. All rights reserved.
//

#import "OneLongImageTableViewCell.h"

#import "NewsModel.h"
#import "UIImageView+WebCache.h"
@implementation OneLongImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        if ([UIScreen mainScreen].bounds.size.width == 320) {
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width + 35, 30)];
            _iamge = [[UIImageView alloc] initWithFrame:CGRectMake(10, 28, self.bounds.size.width - 20, 115)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, self.bounds.size.width - 10, 40)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 120, 40, 40)];
            _iamge2Name = [[UILabel alloc] initWithFrame:CGRectMake(65, 140, 150, 20)];
        }else if([UIScreen mainScreen].bounds.size.width == 375){
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width + 35, 30)];
            _iamge = [[UIImageView alloc] initWithFrame:CGRectMake(10, 28, self.bounds.size.width + 35, 115)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, self.bounds.size.width + 35, 40)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 120, 40, 40)];
            _iamge2Name = [[UILabel alloc] initWithFrame:CGRectMake(65, 140, 150, 20)];
            
        }else{
            _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, self.bounds.size.width + 75, 30)];
            _iamge = [[UIImageView alloc] initWithFrame:CGRectMake(10, 28, self.bounds.size.width + 75, 115)];
            _introduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, self.bounds.size.width + 75, 40)];
            _iamge2 = [[UIImageView alloc] initWithFrame:CGRectMake(20, 120, 40, 40)];
            _iamge2Name = [[UILabel alloc] initWithFrame:CGRectMake(65, 140, 150, 20)];
        }
        
        _introduceLabel.alpha = 0.8;
        _introduceLabel.font = [UIFont systemFontOfSize:15];
        _introduceLabel.numberOfLines = 0;
        _iamge2.layer.cornerRadius = 20;
        _iamge2.layer.masksToBounds = YES;
        _iamge2Name.alpha = 0.7;
        _iamge2Name.textColor = [UIColor redColor];
        _iamge2Name.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_introduceLabel];
        [self.contentView addSubview:_iamge];
        [self.contentView addSubview:_iamge2];
        [self.contentView addSubview:_iamge2Name];
    }
    return self;
}

- (void)setNewsModel:(NewsModel *)newsModel
{
    _newsModel = newsModel;
    [_iamge sd_setImageWithURL:[NSURL URLWithString:self.newsModel.imgsrc] placeholderImage:[UIImage imageNamed:@"Kplace"]];
    if (self.newsModel.editor.count != 0) {
        [_iamge2 sd_setImageWithURL:[NSURL URLWithString:[self.newsModel.editor[0] objectForKey:@"editorImg"]] placeholderImage:[UIImage imageNamed:@"Kplace"]];
        _iamge2Name.text = [self.newsModel.editor[0] objectForKey:@"editorName"];
    }
    
    _titleLabel.text = self.newsModel.title;
    _introduceLabel.text = self.newsModel.digest;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
